Skip to main content

All Questions

5votes
6answers
2kviews

Is it a good idea to return a Builder from a Factory?

I would want to have a builder for creating a complex object, for example Employee. I would want to be able to create my objects in two ways: Case 1. Get Employee with default values Case 2. Get ...
CuriousGuy's user avatar
2votes
2answers
2kviews

Creational design pattern that allows configuration of objects

With the factory pattern we abstract the creation of objects. But what if we need a specific configuration of an object that depends on the calling context? Example: So I have a Builder pattern for ...
Jim's user avatar
  • 359
37votes
9answers
18kviews

Why do we need a Builder class when implementing a Builder pattern?

I have seen many implementations of the Builder pattern (mainly in Java). All of them have an entity class (let's say a Person class), and a builder class PersonBuilder. The builder "stacks" a variety ...
Boyan Kushlev's user avatar
2votes
2answers
2kviews

Is it an antipattern to introduce complexity into a builder?

I've looked at various definitions of the builder pattern and whilst there's varying definitions, they tend to be focused on the broad definition of incremental construction. However, it seems that ...
Kevin Raoofi's user avatar
5votes
1answer
15kviews

Is mixing Builders and Factory pattern a good idea?

I have an object Carconstructed using builder pattern. Issue was a lot of code redundancy. Car.Builder builder = new Car.Builder("Mercedes"); builder.numDoors(carConfig.getNumDoors() ...
JavaDeveloper's user avatar
14votes
5answers
11kviews

Is it strange for a Builder object to have getter methods?

I have a fairly complex immutable data type that I'm using a builder object to instantiate. Currently, I have a setup where I parse a file, setting various fields in my builder, and then build the ...
codebreaker's user avatar
23votes
5answers
2kviews

Why would a type be coupled with its builder?

I've recently deleted a java answer of mine on Code Review, that started like this: private Person(PersonBuilder builder) { Stop. Red flag. A PersonBuilder would build a Person; it knows about a ...
Mathieu Guindon's user avatar
2votes
1answer
6kviews

Intelligent builder pattern - different parameters depending on type - generics?

Lets say we have the famous Joshua Bloch Nutrition Builder and we want to change it so it be a bit like dynamic builder which restricts visibility of setters and propably uses generics : public ...
user1308908's user avatar

close